﻿<Window x:Class="GeometryViz3D.Views.EditModelDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:GeometryViz3D.ValueConverters"
    Title="{Binding Title}" Height="400" Width="600" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterOwner">
    <Window.Resources>
        <DataTemplate x:Key="xCellTemplate">
            <TextBox Text="{Binding X}"  Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="yCellTemplate">
            <TextBox Text="{Binding Y}"  Margin="-6, 0, -6, 0" />
        </DataTemplate>
        <DataTemplate x:Key="zCellTemplate">
            <TextBox Text="{Binding Z}"  Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="labelCellTemplate">
            <TextBox Text="{Binding Label}"  Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="startPointCellTemplate">
            <ComboBox ItemsSource="{Binding Path=AvailablePoints}"
                      SelectedValue="{Binding StartPoint}"
                      Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="endPointCellTemplate">
            <ComboBox ItemsSource="{Binding AvailablePoints}" 
                      SelectedValue="{Binding EndPoint}"
                      Margin="-6, 0, -6, 0"/>
        </DataTemplate>
        <DataTemplate x:Key="colorCellTemplate">
            <ComboBox ItemsSource="{Binding Colors}"
                      SelectedValue="{Binding Color}"
                      ItemTemplate="{StaticResource colorComboBoxItemTemplate}"
                      Margin="-6, 0, -6, 0" >
            </ComboBox>
        </DataTemplate>
    </Window.Resources>
    
    <DockPanel Margin="3">
        <StackPanel DockPanel.Dock="Right" MinWidth="80" Margin="0, 8, 0, 0">
            <Button Content="OK" 
                    Command="{Binding OKCommand}"
                    Margin="2" 
                    IsDefault="True" />
            <Button Content="Cancel" 
                    Margin="2" 
                    IsCancel="True" />
            <Label/>
            <Button Content="Add Point"
                    Command="{Binding AddPointCommand}"
                    Margin="2" />
            <Button Content="Add Line"
                    Command="{Binding AddLineCommand}"
                    Margin="2" />
            <Label/>
            <Button Content="Delete Point"
                    Command="{Binding DeletePointCommand}"
                    Margin="2" />
            <Button Content="Delete Line"
                    Command="{Binding DeleteLineCommand}"
                    Margin="2" />
        </StackPanel>
        <Border>
            <TabControl Margin="3">
                <TabItem Header="Points">
                    <ListView Margin="3" 
                          ItemsSource="{Binding Points}" 
                          SelectedValue="{Binding SelectedPoint}" >
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.View>
                            <GridView>
                                <GridView.Columns>
                                    <GridViewColumn Header="Label" Width="80"
                                                CellTemplate="{StaticResource labelCellTemplate}" />
                                    <GridViewColumn Header="X" Width="80" 
                                                CellTemplate="{StaticResource xCellTemplate}" />
                                    <GridViewColumn Header="Y" Width="80"
                                                CellTemplate="{StaticResource yCellTemplate}" />
                                    <GridViewColumn Header="Z" Width="80"
                                                CellTemplate="{StaticResource zCellTemplate}" />
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </TabItem>
                <TabItem Header="Lines">
                    <ListView Margin="3" 
                          ItemsSource="{Binding Lines}"
                          SelectedValue="{Binding SelectedLine}">
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </ListView.ItemContainerStyle>
                        <ListView.View>
                            <GridView>
                                <GridView.Columns>
                                    <GridViewColumn Header="Point 1" Width="120"
                                                CellTemplate="{StaticResource startPointCellTemplate}" />
                                    <GridViewColumn Header="Point 2" Width="120"
                                                CellTemplate="{StaticResource endPointCellTemplate}" />
                                    <GridViewColumn Header="Color" Width="120"
                                                CellTemplate="{StaticResource colorCellTemplate}" />
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </TabItem>
                <TabItem Header="Planes">
                    
                </TabItem>
            </TabControl>
        </Border>
    </DockPanel>
</Window>
